package com.hutao.sso.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hutao.sso.util.HttpClientUtil;
import com.hutao.sso.util.JsonUtil;
import com.hutao.sso.util.Result;

@RequestMapping("/basic")
@Controller
public class BasicDataController {

	@Value("${medical.manage.static.getChooseOfficeCode.url}")
	private String getChooseOfficeCodeUrl;
	
	@GetMapping("/getChooseOfficeCode")
	@ResponseBody
	public Map<String, Object> getChooseOfficeCode(String code) {
		Map<String, Object> resultMap = new HashMap<>();
		Map<String, String> params = new HashMap<>();
		params.put("code", code);
		String jsonStr = HttpClientUtil.doPost(getChooseOfficeCodeUrl, params);
		Result result = JsonUtil.jsonToPojo(jsonStr, Result.class);
		
		if (result.isSuccess()) {
			resultMap.put("offices", result.getData());
		} else {
			resultMap.put("offices", null);
		}
		
		return resultMap;
		
		
	}
	
	
	
	
	
}
